/**
 * @author tianchao
 */
import request from '@/utils/request'

/**
 * 查询字典项
 */
export function getDictByCode(dictCode) {
  return request({
    baseURL: '/API-ENTERPRISE-BACKEND/',
    url: '/backend/sysDictionary/getDictByCode',
    method: 'get',
    params: { dictCode }
  })
}

/**
 * 获取菜单权限树(异步)也可以用于下拉选择以及菜单
 */
export function getComTreeSync(parentId) {
  return request({
    baseURL: '/API-ENTERPRISE-BACKEND/',
    url: '/backend/orgInfo/getLeaf',
    method: 'get',
    params: { parentId }
  })
}

/**
 * 查询菜单树
 */
export function queryMenu(data) {
  return request({
    baseURL: '/API-ENTERPRISE-BACKEND/',
    url: 'backend/menu/queryMenu',
    method: 'post',
    data
  })
}

/**
 * 根据ids查询菜单列表（用于选择发布菜单数据回显）
 */
export function getSelectCompany(data) {
  return request({
    baseURL: '/API-ENTERPRISE-BACKEND/',
    url: '/backend/orgInfo/queryEnterprise',
    method: 'post',
    data
  })
}
/**
 * 新增一级菜单信息
 * @param {*} data
 */
export function createFirst(data) {
  return request({
    baseURL: '/API-ENTERPRISE-BACKEND/',
    url: '/backend/menu/updateMenu',
    method: 'post',
    data
  })
}
/**
 * 新增下级菜单信息
 * @param {*} data
 */
export function insert(data) {
  return request({
    baseURL: '/API-ENTERPRISE-BACKEND/',
    url: '/backend/menu/updateMenu',
    method: 'post',
    data
  })
}
/**
 * 编辑下级菜单信息
 * @param {*} data
 */
export function update(data) {
  return request({
    baseURL: '/API-ENTERPRISE-BACKEND/',
    url: '/backend/menu/updateMenu',
    method: 'post',
    data
  })
}
/**
 * 编辑下级菜单信息
 * @param {*} id
 */
export function get(id) {
  return request({
    baseURL: '/API-ENTERPRISE-BACKEND/',
    url: '/backend/menu/get',
    method: 'get',
    params: { id }
  })
}
/**
 * 删除菜单信息
 * @param {*} id
 */
export function del(id) {
  return request({
    baseURL: '/API-ENTERPRISE-BACKEND/',
    url: '/backend/menu/deleteMenu',
    method: 'get',
    params: { id }
  })
}

